package day10.download;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Server {
    public static void main(String[] args) throws IOException {
        //创建服务端套接字
        ServerSocket ss = new ServerSocket(6666);

        //创建线程池
        ExecutorService pool = Executors.newFixedThreadPool(30);

        while (true) {
            Socket s = ss.accept();
            //写一个封装到线程类里面
            //try这块代码块写到run方法里面
            // new 这个线程类,启动线程
            Upload u = new Upload(s);

            //提交任务
            pool.submit(u);
        }
    }
}
